<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>Mongoose ODM v5.4.20-pre</title><link href="//fonts.googleapis.com/css?family=Anonymous+Pro:400,700|Droid+Sans+Mono|Open+Sans:400,700|Linden+Hill|Quattrocento:400,700|News+Cycle:400,700|Antic+Slab|Cabin+Condensed:400,700" rel="stylesheet" type="text/css"><link href="docs/css/default.css" rel="stylesheet"><link href="docs/css/style.css" rel="stylesheet"><link href="/docs/css/github.css" rel="stylesheet"><style>code {
  font-size: 1em;
}

.sponsor {
  margin-bottom: 40px;
  font-size: 0.66em;
  color: #666;
  text-decoration: none;
}

.sponsors {
  margin-bottom: 40px;
}

.sponsors a {
  text-decoration: none;
}

.carbonad{
  margin-top:0!important;
  margin-bottom:-3rem!important
}

#carbonads {
  position:fixed;
  right: 0px;
  bottom: 0px;
  display:block;
  width:200px;
  padding:15px 15px 15px 160px;
  overflow:hidden;
  font-size:13px;
  line-height:1.4;
  text-align:left;
  background-color: #fafafa;
}

@media (max-width: 1160px) {
  #carbonads {
    display: none !important;
  }
}

#carbonads a{color:#333;text-decoration:none}

.carbon-img{float:left;margin-left:-145px}

.carbon-poweredby{display:block;color:#777!important}

img.sponsor {
  margin-right: 10px;
  border: 1px dotted #dfdfdf;
  height: 100px;
}
</style></head><body><a id="forkbanner" href="http://github.com/learnboost/mongoose"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub"></a><div id="wrap" class="homepage"><div id="header"><h1><a href="https://github.com/Automattic/mongoose" target="blank"><div class="mongoose">Mongoose</div></a></h1></div><div class="tagline"><p>Elegant <a href="https://www.mongodb.com/">MongoDB</a> object modeling for
<a href="https://nodejs.org/en/">Node.js</a></p>
</div><div id="links"><ul><li><a href="docs/guide.html">Read the Docs</a></li><li><a href="http://plugins.mongoosejs.io">Discover Plugins</a></li></ul></div><div id="follow"><ul><li><iframe src="//ghbtns.com/github-btn.html?user=Automattic&amp;repo=mongoose&amp;type=watch&amp;count=true" allowtransparency="true" frameborder="0" scrolling="0" width="100px" height="20px" class="github-btn"></iframe></li><li id="version"><span>Version 5.4.20-pre</span></li><li><iframe src="//ghbtns.com/github-btn.html?user=Automattic&amp;repo=mongoose&amp;type=fork&amp;count=true" allowtransparency="true" frameborder="0" scrolling="0" width="100px" height="20px" class="github-btn"></iframe></li></ul></div><div id="inner"><div id="what"><p class="what">Let's face it,&nbsp;<strong>writing MongoDB validation, casting and business logic boilerplate is a drag</strong>. That's why we wrote Mongoose.</p></div><pre><code class="lang-javascript"><span class="hljs-keyword">const</span> mongoose = <span class="hljs-built_in">require</span>(<span class="hljs-string">'mongoose'</span>);
mongoose.connect(<span class="hljs-string">'mongodb://localhost:27017/test'</span>, {useNewUrlParser: <span class="hljs-literal">true</span>});

<span class="hljs-keyword">const</span> Cat = mongoose.model(<span class="hljs-string">'Cat'</span>, { name: <span class="hljs-built_in">String</span> });

<span class="hljs-keyword">const</span> kitty = <span class="hljs-keyword">new</span> Cat({ name: <span class="hljs-string">'Zildjian'</span> });
kitty.save().then(() =&gt; <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'meow'</span>));
</code></pre>
<p>Mongoose provides a straight-forward, schema-based solution to model
your application data. It includes built-in type casting, validation,
query building, business logic hooks and more, out of the box.</p>
<div id="tidelift"><a id="tidelift-button" href="https://tidelift.com/subscription/pkg/npm-mongoose?utm_source=npm-mongoose&utm_medium=website">
  <img src="/docs/images/tidelift.svg" />
  <span>Get Professionally Supported Mongoose</span>
</a>
</div><div class="carbon-ad"><script async type="text/javascript" src="//cdn.carbonads.com/carbon.js?zoneid=1673&serve=C6AILKT&placement=mongoosejscom" id="_carbonads_js"></script></div><h2 id="getting-started">Getting Started</h2>
<ul>
<li><a href="/docs/index.html">quick start guide</a></li>
</ul>
<h2 id="support">Support</h2>
<ul>
<li><a href="http://stackoverflow.com/questions/tagged/mongoose">Stack Overflow</a></li>
<li><a href="https://github.com/Automattic/mongoose/issues">GitHub Issues</a></li>
<li><a href="https://gitter.im/Automattic/mongoose">Gitter Chat</a></li>
<li><a href="http://www.mongodb.org/about/support/">MongoDB Support</a></li>
</ul>
<h2 id="news">News</h2>
<ul>
<li><a href="https://twitter.com/mongoosejs">Twitter</a></li>
</ul>
<h2 id="changelog">Changelog</h2>
<ul>
<li><a href="https://github.com/Automattic/mongoose/blob/master/History.md">Changelog</a></li>
</ul>
<h2 id="sponsors">Sponsors</h2>
<div class="sponsors">
  <div>
    <a href="https://mixmax.com">
      <img class="sponsor" src="/docs/images/mixmax.png" alt="MixMax.com">
    </a>
    <a href="https://localizejs.com/">
      <img class="sponsor" src="//ww1.prweb.com/prfiles/2015/10/28/13050459/localize-logo-black.png">
    </a>
    <a href="https://frontendmasters.com/">
      <img class="sponsor" src="https://images.opencollective.com/proxy/images?src=https%3A%2F%2Fopencollective-production.s3-us-west-1.amazonaws.com%2F5e18b6b0-83b4-11e8-97c9-03259cc8bf2b.png&height=100" alt="Frontend Masters">
    </a>
    <a href="https://www.codefirst.co.uk/">
      <img class="sponsor" src="https://images.opencollective.com/proxy/images?src=https%3A%2F%2Fopencollective-production.s3-us-west-1.amazonaws.com%2Fdde88120-e914-11e8-a662-278259d35390.png&height=100">
    </a>
    <a href="https://www.vpsserver.com/">
      <img class="sponsor" src="https://images.opencollective.com/proxy/images?src=https%3A%2F%2Flogo.clearbit.com%2Fvpsserver.com&height=100">
    </a>
    <a href="https://icons8.com/">
      <img class="sponsor" src="https://s3.amazonaws.com/codebarbarian-images/Icons8+Logo+500px.png" style="height:100px">
    </a>
    <a href="https://topvet.net/">
      <img class="sponsor" src="https://images.opencollective.com/proxy/images?src=https%3A%2F%2Flogo.clearbit.com%2Ftopvet.net&height=100" style="height:100px">
    </a>
    <a href="https://www.dontpayfull.com/">
      <img class="sponsor" src="https://images.opencollective.com/proxy/images?src=https%3A%2F%2Fopencollective-production.s3-us-west-1.amazonaws.com%2F84c4ba80-1955-11e8-8343-278614155b3e.png&height=100" style="height:100px">
    </a>
    <a href="https://marcus-hiles.com/">
      <img class="sponsor" src="https://images.opencollective.com/proxy/images?src=https%3A%2F%2Fwww.gravatar.com%2Favatar%2F18234f5f0ed822f7b879f50b285c47eb%3Fdefault%3D404&height=100" style="height:100px">
    </a>
    <a href="https://domainwheel.com/">
      <img class="sponsor" src="https://s25990.pcdn.co/wp-content/themes/namegenerator/img/logo_dw.jpg" style="height:100px">
    </a>
    <a href="https://views.guru/">
      <img class="sponsor" src="https://images.opencollective.com/proxy/images?src=https%3A%2F%2Fopencollective-production.s3-us-west-1.amazonaws.com%2F3f5383a0-2bba-11e9-ab5d-8fd7c8a252c0.jpg&height=100" style="height:100px">
    </a>
    <a href="https://uiuxagencies.top/">
      <img class="sponsor" src="https://images.opencollective.com/proxy/images?src=https%3A%2F%2Fopencollective-production.s3-us-west-1.amazonaws.com%2F62223ab0-f4f7-11e8-919f-53f2ea21a967.png&height=100" style="height:100px">
    </a>
    <a href="https://www.gameserverkings.com/">
      <img class="sponsor" src="https://images.opencollective.com/proxy/images?src=https%3A%2F%2Flogo.clearbit.com%2Fgameserverkings.com&height=100" style="height:100px">
    </a>
  </div>
</div>

<div class="sponsor">
  Sponsor <a href="https://opencollective.com/mongoose">Mongoose on OpenCollective</a> to get your company&#39;s logo above!
</div>
</div></div><p id="footer">Licensed under MIT. Copyright 2011 <a href="http://learnboost.com">LearnBoost</a>.</p><script>document.body.className = 'load';</script><script type="text/javascript">!function(name,path,ctx){
  var latest,prev=name!=='Keen'&&window.Keen?window.Keen:false;ctx[name]=ctx[name]||{ready:function(fn){var h=document.getElementsByTagName('head')[0],s=document.createElement('script'),w=window,loaded;s.onload=s.onerror=s.onreadystatechange=function(){if((s.readyState&&!(/^c|loade/.test(s.readyState)))||loaded){return}s.onload=s.onreadystatechange=null;loaded=1;latest=w.Keen;if(prev){w.Keen=prev}else{try{delete w.Keen}catch(e){w.Keen=void 0}}ctx[name]=latest;ctx[name].ready(fn)};s.async=1;s.src=path;h.parentNode.insertBefore(s,h)}}
}('KeenAsync','https://d26b395fwzu5fz.cloudfront.net/keen-tracking-1.1.3.min.js',this);

KeenAsync.ready(function(){
  // Configure a client instance
  var client = new KeenAsync({
    projectId: '59aad9cbc9e77c0001ce1b32',
    writeKey: '4B38B0046086885E425D368BFAEAD8FD0D4F2DC2FA2F936FDE058D79508AEFAD9886BC020B96520823BB9C8241D9D9BCFDC0EF52E6033BD89D06E4B24FC13AE955896BF443406269A84DD009CEB5862DCEC944874DB2107FD648DA91ADC1E6DE'
  });

  client.recordEvent('pageView', {
    host: window.location.host,
    pathname: window.location.pathname,
    hash: window.location.hash
  });
});</script></body></html>